package com.gitee.wsl.mathematics.vector.ext

import com.gitee.wsl.mathematics.vector.Vector

private fun differentDimException(a: Vector<*, *>, b:  Vector<*, *>) =
    IllegalArgumentException("operate two vector of different dim (${a.dim} and ${b.dim})")

fun<T:Number,V: Vector<T, V>> Vector<T, V>.zip(other:Vector<T, *>, block:(a:T, b:T)->T)
    = takeIf { dim == other.dim }
    ?.let { create( proxy.zip(other.proxy){ a,b -> block(a,b) } ) }
    ?: throw differentDimException(this, other)
